package com.dongline.test.huizongliuliang;

import com.dongline.test.simple.WordCountDriver;
import com.dongline.test.simple.WordCountMapper;
import com.dongline.test.simple.WordCountReducer;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;

import java.io.IOException;

public class FlowDriver {

    public static void main(String[] args) throws IOException, ClassNotFoundException, InterruptedException {

        Configuration configuration = new Configuration();


        Job job=Job.getInstance(configuration);

        ///这句话很重要必须加上
        job.setJarByClass(FlowDriver.class);


        job.setMapperClass(FlowMapper.class);
        job.setReducerClass(FlowReducer.class);


        job.setMapOutputKeyClass(Text.class);
        job.setMapOutputValueClass(FlowWritable.class);



        job.setOutputKeyClass(Text.class);
        job.setOutputValueClass(FlowWritable.class);





        FileInputFormat.setInputPaths(job,new Path(args[0]));
        FileOutputFormat.setOutputPath(job,new Path(args[1]));



//        job.setCombinerClass();可以设置一个Combiner，功能类似于reducer，但是是运行在maptask上的。maptask自己数据进行分区排序之前调用一次。分区排序后调用一次。业务场景



        boolean re= job.waitForCompletion(true);

        System.exit(re?0:1);
    }
}
